/**
 * Created by guiyongdong on 16/9/29.
 */


export  default class  HomeParseData {
    //解析首页数据
    parseData(data){
        //总数据
        var dataBlob = {};
        //区头type数据
        var sectionIDs = [];
        //row数据
        var rowIDs = [];
        for(var ii = 0; ii < data.length; ii++) {
            var type = data[ii]['type'];
            sectionIDs.push(type);
            dataBlob[type] = data[ii];
            rowIDs[ii] = [];
            if(type == 'carousel') {
                /** carousel 轮播图 */
                rowIDs[ii].push(type);
            }else if(type == 'icon') {
                //icon
                rowIDs[ii].push(type);
            }else if(type == 'sec_kill_round_info') {
                /** sec_kill_round_info 秒杀 */
                rowIDs[ii].push(type);
            }else if(type == 'guess_you_like') {
                /** guess_you_like 猜你喜欢 */
                rowIDs[ii].push(type);
            }else if(type == 'hot_sale_good') {
                /** hot_sale_good 热卖商品 */
                var itemArray = data[ii][type];
                var goodArray = [];
                for(var j = 0 ; j < itemArray.length/2; j++){
                    var rowId = j;
                    goodArray.push(rowId);
                }
                rowIDs[ii] = goodArray;
            }else if(type == 'singlemap') {
                /** 一图 singlemap */
                rowIDs[ii].push(type);
            }else if(type == 'fourspace') {
                /** 四图 fourspace */
                rowIDs[ii].push(type);
            }else if(type == 'announcement') {
                /** 小达快讯 */
                rowIDs[ii].push(type);
            }else if(type == 'subject_product_list') {
                /** 两个商品 */
                var itemArray = data[ii][type];
                var goodArray = [];
                for(var j = 0 ; j < itemArray.length/2; j++){
                    goodArray.push(j);
                }
                rowIDs[ii] = goodArray;
            }else if(type == 'subject_3_l_picture') {
                /** 三图左 */
                rowIDs[ii].push(type);
            }else if(type == 'subject_3_r_picture') {
                /** 三图右 */
                rowIDs[ii].push(type);
            }else if(type == 'subject_2_picture') {
                /** 两图 */
                rowIDs[ii].push(type);
            }
        }
        var returnData = {};
        returnData['dataBlob'] = dataBlob;
        returnData['sectionIDs'] = sectionIDs;
        returnData['rowIDs'] = rowIDs;
        return returnData;
    }
    
}